﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_DeleteUser_BasicReferences')
	BEGIN
		DROP  Procedure  [esf_sso].P_DeleteUser_BasicReferences
	END

GO

CREATE Procedure [esf_sso].P_DeleteUser_BasicReferences
	@pUserPersonID	INT
	,@pBasicReferenceTypeID	INT
AS

	DELETE FROM [esf_sso].User_BasicReference 
	WHERE 
		UserPersonID = @pUserPersonID
		AND BasicReferenceID IN (SELECT ID FROM esf_sso.BasicReference WHERE BasicReferenceTypeID = @pBasicReferenceTypeID)

GO